//
//  OrderFirstRowCell.m
//  随便点
//
//  Created by ZC on 15/3/26.
//  Copyright (c) 2015年 qfsoft. All rights reserved.
//

#import "OrderFirstRowCell.h"

@implementation OrderFirstRowCell


- (void)awakeFromNib {
    
    [self WC];
    self.datepicker.datePickerMode=UIDatePickerModeCountDownTimer;
    [self.datepicker setBackgroundColor:[UIColor brownColor]];
    [self.datepicker addTarget:self action:@selector(DatePickerValueChange:) forControlEvents:UIControlEventValueChanged];
    self.datepicker.hidden = YES;
    
    //设置默认时间
    NSDate *select = [NSDate date];
    NSDateFormatter *selectDateFormatter=[[NSDateFormatter alloc]init];
    selectDateFormatter.dateFormat=@"HH:mm";
    NSString *dateAndTime=[selectDateFormatter stringFromDate:select];
    self.timeField.text=dateAndTime;
    
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

}


- (IBAction)ButtonClick:(id)sender {
    
    if (_SheZhi.tag==1) {
        [self WC];
        _SheZhi.tag=0;
    }
    else{
        [self SZ];
        _SheZhi.tag=1;
    }
    
}
-(void)WC{
    _SheZhi.backgroundColor=[UIColor colorWithPatternImage:[UIImage imageNamed:@"shezhi.png"]];
    self.datepicker.hidden=YES;
}
-(void)SZ{
    _SheZhi.backgroundColor=[UIColor colorWithPatternImage:[UIImage imageNamed:@"wancheng.png"]];
    self.datepicker.hidden=NO;
}


-(void)DatePickerValueChange:(UIDatePicker *)sender{
    NSDate *select = [sender date];
    NSDateFormatter *selectDateFormatter=[[NSDateFormatter alloc]init];
    selectDateFormatter.dateFormat=@"HH:mm";
    NSString *dateAndTime=[selectDateFormatter stringFromDate:select];
    self.timeField.text=dateAndTime;
    
    
}
@end
